package base.day24;

import java.io.*;

public class MyCharacterStream10 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        User user=new User("zhangsan","123456");
        BufferedWriter bw=new BufferedWriter(new FileWriter("C:\\Users\\SuperJohn\\Desktop\\abc.txt"));
        bw.write(user.getUser());
        bw.newLine();
        bw.write(user.getPassword());
        bw.close();


        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("C:\\Users\\SuperJohn\\Desktop\\abc.txt"));
        oos.writeObject(user);
        oos.close();

        ObjectInputStream ois=new ObjectInputStream(new FileInputStream("C:\\Users\\SuperJohn\\Desktop\\abc.txt"));
        User o =(User) ois.readObject();
        System.out.println(o);
    }

}
